package model.dao;

import java.util.List;

import vo.AdminVO;

import com.ibatis.sqlmap.client.SqlMapClient;

public class AdminDAO {

	private SqlMapClient client;
	
	private static AdminDAO dao=new AdminDAO();
	
	private AdminDAO(){
		SqlMapFactory factory = SqlMapFactory.getInstance();
		client = factory.getClient();
	}
	
	public static AdminDAO getinstance(){
		if(dao==null) dao=new AdminDAO();
		return dao;
	}
	
	public List selectAllMember(int pageNo) throws Exception{
		List list=client.queryForList("admin.selectAllMember", pageNo);		
		return list;
	}
	
	public int selectAllCount() throws Exception{
		int count=(Integer) client.queryForObject("admin.selectAllCount");
		return count;		
	}
	
	public AdminVO selectById(String id) throws Exception{			
		AdminVO avo=(AdminVO) client.queryForObject("admin.selectById", id);			
		return avo;		
	}
	
	public int selectCountProduct(String id) throws Exception{
		int count=(Integer) client.queryForObject("admin.selectCountProduct", id);
		return count;	
	}
	
	public int selectCountVendor(String id) throws Exception{
		int count=(Integer) client.queryForObject("admin.selectCountVendor", id);
		return count;	
	}
	
	public int selectCountCustomer(String id)throws Exception{
		int count=(Integer) client.queryForObject("admin.selectCountCustomer", id);
		return count;	
	}
	
	public int selectCountStock(String id)throws Exception{
		int count=(Integer) client.queryForObject("admin.selectCountStock", id);
		return count;	
	}
	
	public int selectCountSale(String id)throws Exception{
		int count=(Integer) client.queryForObject("admin.selectCountSale", id);
		return count;	
	}
	
	public int update(String id) throws Exception {
		int cnt=(Integer) client.update("admin.updateMember", id);		
		return cnt;
	}

	
}
